﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core.IRepository;
using System.Data.Entity;

namespace Repositories
{
    public class UnitOfWork<TDbContext> : IUnitOfWork
        where TDbContext : DbContext
    {
        private readonly TDbContext context;

        public UnitOfWork(TDbContext context)
        {
            this.context = context;
        }

        public bool Commit()
        {
            return context.SaveChanges() > 0;
        }

        public void Dispose()
        {
            context.Dispose();
        }
    }
}
